home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple WWDC 1996
/
WWDC96_1996 (CD).toast
/
Technology Materials
/
MacOS 8 Resources
/
Developer Tools
/
Mac OS 8 Interfaces & Libraries
/
Interfaces
/
CIncludes
/
Resources.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-01
|
14KB
|
443 lines
/*
File: Resources.h
Contains: Resource Manager Interfaces.
Version: Technology: System 7.5
Release: Universal Interfaces 3.0d3 on Copland DR1
Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
Bugs?: If you find a problem with this file, send the file and version
information (from above) and the problem description to:
Internet: apple.bugs@applelink.apple.com
AppleLink: APPLE.BUGS
*/
#ifndef __RESOURCES__
#define __RESOURCES__
#ifndef __TYPES__
#include <Types.h>
#endif
#ifndef __MIXEDMODE__
#include <MixedMode.h>
#endif
#ifndef __FILES__
#include <Files.h>
#endif
#if FOR_SYSTEM8_COOPERATIVE
#ifndef __FILEMANAGERTYPES__
#include <FileManagerTypes.h>
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT_SUPPORTED
#pragma import on
#endif
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=mac68k
#endif
/*
InitResources and RsrcZoneInit are no longer needed in Copland.
* CFM provides the necessary run time initialization entry points.
*/
#if FOR_SYSTEM7_ONLY
extern pascal short InitResources(void )
ONEWORDINLINE(0xA995);
extern pascal void RsrcZoneInit(void )
ONEWORDINLINE(0xA996);
#endif
#if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
enum {
resSysHeap = 64, /*System or application heap?*/
resPurgeable = 32, /*Purgeable resource?*/
resLocked = 16, /*Load it in locked?*/
resProtected = 8, /*Protected?*/
resPreload = 4, /*Load in on OpenResFile?*/
resChanged = 2, /*Resource changed?*/
mapReadOnly = 128, /*Resource file read-only*/
mapCompact = 64, /*Compact resource file*/
mapChanged = 32, /*Write map out at update*/
resSysRefBit = 7, /*reference to system/local reference*/
resSysHeapBit = 6, /*In system/in application heap*/
resPurgeableBit = 5, /*Purgeable/not purgeable*/
resLockedBit = 4, /*Locked/not locked*/
resProtectedBit = 3, /*Protected/not protected*/
resPreloadBit = 2, /*Read in at OpenResource?*/
resChangedBit = 1, /*Existing resource changed since last update*/
mapReadOnlyBit = 7, /*is this file read-only?*/
mapCompactBit = 6, /*Is a compact necessary?*/
mapChangedBit = 5, /*Is it necessary to write map?*/
kResFileNotOpened = -1, /*ref num return as error when opening a resource file*/
kSystemResFile = 0 /*this is the default ref num to the system file*/
};
/*
This ProcPtr uses register based parameters on the 68k and cannot
be written in or called from a high-level language without the help of
mixed mode or assembly glue.
typedef pascal void (*ResErrProcPtr)(OSErr thErr);
*/
#if GENERATINGCFM
typedef UniversalProcPtr ResErrUPP;
#else
typedef Register68kProcPtr ResErrUPP;
#endif
enum {
uppResErrProcInfo = kRegisterBased
| REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(OSErr)))
};
#if GENERATINGCFM
#define NewResErrProc(userRoutine) \
(ResErrUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppResErrProcInfo, GetCurrentArchitecture())
#else
#define NewResErrProc(userRoutine) \
((ResErrUPP) (userRoutine))
#endif
#if GENERATINGCFM
#define CallResErrProc(userRoutine, thErr) \
CallUniversalProc((UniversalProcPtr)(userRoutine), uppResErrProcInfo, (thErr))
#else
/* (*ResErrUPP) cannot be called from a high-level language without the Mixed Mode Manager */
#endif
#endif
#if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
extern pascal void CloseResFile(short refNum)
ONEWORDINLINE(0xA99A);
extern pascal short ResError(void )
ONEWORDINLINE(0xA9AF);
extern pascal short CurResFile(void )
ONEWORDINLINE(0xA994);
extern pascal short HomeResFile(Handle theResource)
ONEWORDINLINE(0xA9A4);
extern pascal void CreateResFile(ConstStr255Param fileName)
ONEWORDINLINE(0xA9B1);
extern pascal short OpenResFile(ConstStr255Param fileName)
ONEWORDINLINE(0xA997);
extern pascal void UseResFile(short refNum)
ONEWORDINLINE(0xA998);
extern pascal short CountTypes(void )
ONEWORDINLINE(0xA99E);
extern pascal short Count1Types(void )
ONEWORDINLINE(0xA81C);
extern pascal void GetIndType(ResType *theType, short index)
ONEWORDINLINE(0xA99F);
extern pascal void Get1IndType(ResType *theType, short index)
ONEWORDINLINE(0xA80F);
extern pascal void SetResLoad(Boolean load)
ONEWORDINLINE(0xA99B);
extern pascal short CountResources(ResType theType)
ONEWORDINLINE(0xA99C);
extern pascal short Count1Resources(ResType theType)
ONEWORDINLINE(0xA80D);
extern pascal Handle GetIndResource(ResType theType, short index)
ONEWORDINLINE(0xA99D);
extern pascal Handle Get1IndResource(ResType theType, short index)
ONEWORDINLINE(0xA80E);
extern pascal Handle GetResource(ResType theType, short theID)
ONEWORDINLINE(0xA9A0);
extern pascal Handle Get1Resource(ResType theType, short theID)
ONEWORDINLINE(0xA81F);
extern pascal Handle GetNamedResource(ResType theType, ConstStr255Param name)
ONEWORDINLINE(0xA9A1);
extern pascal Handle Get1NamedResource(ResType theType, ConstStr255Param name)
ONEWORDINLINE(0xA820);
extern pascal void LoadResource(Handle theResource)
ONEWORDINLINE(0xA9A2);
extern pascal void ReleaseResource(Handle theResource)
ONEWORDINLINE(0xA9A3);
extern pascal void DetachResource(Handle theResource)
ONEWORDINLINE(0xA992);
extern pascal short UniqueID(ResType theType)
ONEWORDINLINE(0xA9C1);
extern pascal short Unique1ID(ResType theType)
ONEWORDINLINE(0xA810);
extern pascal short GetResAttrs(Handle theResource)
ONEWORDINLINE(0xA9A6);
extern pascal void GetResInfo(Handle theResource, short *theID, ResType *theType, Str255 name)
ONEWORDINLINE(0xA9A8);
extern pascal void SetResInfo(Handle theResource, short theID, ConstStr255Param name)
ONEWORDINLINE(0xA9A9);
extern pascal void AddResource(Handle theData, ResType theType, short theID, ConstStr255Param name)
ONEWORDINLINE(0xA9AB);
extern pascal long GetResourceSizeOnDisk(Handle theResource)
ONEWORDINLINE(0xA9A5);
extern pascal long GetMaxResourceSize(Handle theResource)
ONEWORDINLINE(0xA821);
extern pascal long RsrcMapEntry(Handle theResource)
ONEWORDINLINE(0xA9C5);
extern pascal void SetResAttrs(Handle theResource, short attrs)
ONEWORDINLINE(0xA9A7);
extern pascal void ChangedResource(Handle theResource)
ONEWORDINLINE(0xA9AA);
extern pascal void RemoveResource(Handle theResource)
ONEWORDINLINE(0xA9AD);
extern pascal void UpdateResFile(short refNum)
ONEWORDINLINE(0xA999);
extern pascal void WriteResource(Handle theResource)
ONEWORDINLINE(0xA9B0);
extern pascal void SetResPurge(Boolean install)
ONEWORDINLINE(0xA993);
extern pascal short GetResFileAttrs(short refNum)
ONEWORDINLINE(0xA9F6);
extern pascal void SetResFileAttrs(short refNum, short attrs)
ONEWORDINLINE(0xA9F7);
extern pascal short OpenRFPerm(ConstStr255Param fileName, short vRefNum, SInt8 permission)
ONEWORDINLINE(0xA9C4);
extern pascal Handle RGetResource(ResType theType, short theID)
ONEWORDINLINE(0xA80C);
extern pascal short HOpenResFile(short vRefNum, long dirID, ConstStr255Param fileName, SInt8 permission)
ONEWORDINLINE(0xA81A);
extern pascal void HCreateResFile(short vRefNum, long dirID, ConstStr255Param fileName)
ONEWORDINLINE(0xA81B);
extern pascal short FSpOpenResFile(const FSSpec *spec, SignedByte permission)
TWOWORDINLINE(0x700D, 0xAA52);
extern pascal void FSpCreateResFile(const FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag)
TWOWORDINLINE(0x700E, 0xAA52);
extern pascal void ReadPartialResource(Handle theResource, long offset, void *buffer, long count)
TWOWORDINLINE(0x7001, 0xA822);
extern pascal void WritePartialResource(Handle theResource, long offset, const void *buffer, long count)
TWOWORDINLINE(0x7002, 0xA822);
extern pascal void SetResourceSize(Handle theResource, long newSize)
TWOWORDINLINE(0x7003, 0xA822);
extern pascal Handle GetNextFOND(Handle fondHandle)
TWOWORDINLINE(0x700A, 0xA822);
/*
Use TempInsertROMMap to force the ROM resource map to be
inserted into the chain in front of the system. Note that
this call is only temporary - the modified resource chain
is only used for the next call to the resource manager.
See IM IV 19 for more information.
*/
extern pascal void TempInsertROMMap(Boolean tempResLoad);
#if CGLUESUPPORTED
extern Handle getnamedresource(ResType theType, const char *name);
extern Handle get1namedresource(ResType theType, const char *name);
extern short openrfperm(const char *fileName, short vRefNum, char permission);
extern short openresfile(const char *fileName);
extern void createresfile(const char *fileName);
extern void getresinfo(Handle theResource, short *theID, ResType *theType, char *name);
extern void setresinfo(Handle theResource, short theID, const char *name);
extern void addresource(Handle theResource, ResType theType, short theID, const char *name);
#endif
#if OLDROUTINENAMES
#define SizeResource(theResource) GetResourceSizeOnDisk(theResource)
#define MaxSizeRsrc(theResource) GetMaxResourceSize(theResource)
#define RmveResource(theResource) RemoveResource(theResource)
#endif
#endif
typedef short ResFileRefNum;
typedef short ResID;
typedef short ResAttributes;
typedef short ResFileAttributes;
enum {
kResFileReadOnlyPermission = 100,
kResFileReadWriteExclusivePermission = 101
};
typedef UInt32 ResFilePermissions;
#if FOR_SYSTEM8_COOPERATIVE
extern OSStatus RMRemoveResFileFromSearchPath(ResFileRefNum refNum);
extern OSStatus RMAddResFileToSearchPath(ResFileRefNum refNum);
/*
* New API returning OSStatus, rolling in low mem, and fixing
* some sins of the past.
*
*/
extern OSStatus RMCreateResFile(FSObjectRef fsFolderObjectRef, FSName fsName, OSType creator, OSType theType);
extern OSStatus RMOpenResFile(FSObjectRef specification, ResFilePermissions permissions, Boolean resLoad, ResFileRefNum *refNum);
extern OSStatus RMCloseResFile(ResFileRefNum refNum);
extern OSStatus RMUpdateResFile(ResFileRefNum refNum);
extern OSStatus RMUseResFile(ResFileRefNum refNum);
extern OSStatus RMCurResFile(ResFileRefNum *refNum);
/*
* We don't want to support resource file attributes other then
* the readOnly bit. Access to the readOnly bit is now gained
* through the calls RMSetResFileReadOnlyState and RMGetResFileReadOnlyState.
*
* So, for now, we will not support RMGetResFileAttrs and RMSetResFileAttrs.
*
* OSStatus RMGetResFileAttrs(ResFileRefNum refNum, ResFileAttributes * attributes);
* OSStatus RMSetResFileAttrs(ResFileRefNum refNum, ResFileAttributes attributes);
*/
extern OSStatus RMHomeResFile(Handle theResource, ResFileRefNum *refNum);
extern OSStatus RMAddResource(Handle theData, ResType theType, ResID theID, ConstStr255Param name);
extern OSStatus RMRemoveResource(Handle theResource);
extern OSStatus RMCountTypes(Boolean oneDeep, UInt32 *count);
extern OSStatus RMGetIndexedType(UInt32 index, Boolean oneDeep, ResType *theType);
extern OSStatus RMCountResources(ResType theType, Boolean oneDeep, UInt32 *count);
extern OSStatus RMGetIndexedResource(ResType theType, UInt32 index, Boolean oneDeep, Boolean resLoad, Handle *handle);
extern OSStatus RMGetResource(ResType theType, ResID theID, Boolean oneDeep, Boolean resLoad, Handle *handle);
extern OSStatus RMGetNamedResource(ResType theType, ConstStr255Param name, Boolean oneDeep, Boolean resLoad, Handle *handle);
extern OSStatus RMLoadResource(Handle theResource);
extern OSStatus RMReleaseResource(Handle theResource);
extern OSStatus RMDetachResource(Handle theResource);
extern OSStatus RMChangedResource(Handle theResource);
extern OSStatus RMWriteResource(Handle theResource);
extern OSStatus RMSetResourceSize(Handle theResource, SInt32 newSize);
extern OSStatus RMUniqueID(ResType theType, Boolean oneDeep, ResID *idPtr);
extern OSStatus RMGetResAttributes(Handle theResource, ResAttributes *attributes);
extern OSStatus RMGetResInfo(Handle theResource, ResType *typePtr, ResID *idPtr, Str255 name);
extern OSStatus RMSetResInfo(Handle theResource, ResType theType, ResID theID, ConstStr255Param name);
extern OSStatus RMSetResAttributes(Handle theResource, ResAttributes attrs);
extern OSStatus RMReadPartialResource(Handle theResource, UInt32 offset, void *buffer, UInt32 count);
extern OSStatus RMWritePartialResource(Handle theResource, UInt32 offset, const void *buffer, UInt32 count);
/*
* GetResourceSize returns either the size of the handle if the handle
* is not empty or the size of the resource as stored on disk (i.e.
* it has the exact semantics of GetResourceSizeOnDisk but does not
* have the confusing name).
*/
extern OSStatus RMGetResourceSize(Handle theResource, SInt32 *size);
extern OSStatus RMSetResErrProc(ResErrUPP proc);
/*
* For now, we don't know if we want to support the purge
* proc in the future... it's an outstanding issue as stated in the
* Design Document.
*
* OSStatus RMSetResPurge(Boolean install);
*/
/*
* The following calls are used to get/set the read only state (i.e. the
* mapReadOnly file attribute) of a resource file. When setting the state,
* the state is set both in memory (i.e. taking affect immediately for all
* other calls) and on disk (i.e. next time the file is opened, it will
* be opened with the read only state set). The call RMSetResFileReadOnlyState
* ignores the current state of the resource file. Setting the read only
* state changes the current resource file attributes of the file both
* in memory and on disk as appropriately (i.e. setting/clearing the read only state
* will set/clear the mapReadOnly bit in memory and on disk).
*
* The read only state is checked when .... [this needs to be filled in -- it
* will be exactly the same as when the mapReadOnly bit is checked].
*/
extern OSStatus RMSetResFileReadOnlyState(ResFileRefNum refNum, Boolean isReadOnly);
extern OSStatus RMGetResFileReadOnlyState(ResFileRefNum refNum, Boolean *isReadOnly);
#endif
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset
#endif
#if PRAGMA_IMPORT_SUPPORTED
#pragma import off
#endif
#ifdef __cplusplus
}
#endif
#endif /* __RESOURCES__ */